package leetcode.code0477;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int totalHammingDistance(int[] nums) {
		int[][] cnts = new int[32][2];
		for (int i = 0; i < nums.length; i++) {
			int num = nums[i];
			for (int j = 0; j < 32; j++) {
				int cur = 1 << j;
				if ((cur & num) == 0) {
					cnts[j][0]++;
				} else {
					cnts[j][1]++;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < cnts.length; i++) {
			ans += cnts[i][0] * cnts[i][1];
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
